<template>
  <basic-container>
    <!-- <el-alert
      title="统计时间：可查询最近三个月的信息"
      type="warning"
      :closable="false"
      style="margin-bottom: 10px"
    >
    </el-alert> -->
    <avue-crud
      :option="option"
      :search.sync="search"
      :table-loading="loading"
      :data="data"
      :page.sync="page"
      :permission="permissionList"
      :before-open="beforeOpen"
      v-model="form"
      ref="crud"
      @search-change="searchChange"
      @search-reset="searchReset"
      @selection-change="selectionChange"
      @current-change="currentChange"
      @size-change="sizeChange"
      @refresh-change="refreshChange"
      @sort-change="sortChange"
    >
      <!-- @on-load="onLoad" -->

      <template slot-scope="{row}" slot="rptPayState">
        <div>
          <el-tag type="success" :color="rptPayStateType(row)" effect="dark">{{row.rptPayStateName}}</el-tag>
        </div>
      </template>
      
      <template slot="menuLeft">
        <div class="curd-foter">
          <div class="redFontBox">总交易笔数：<span class="redFont">{{ exhibition(countData.totalTradeCount) || 0}}</span> 笔</div>
          <div class="redFontBox">总实收金额：<span class="redFont">{{ exhibition(countData.totalRealAmount ) || 0 }}</span> 元</div>
          <div class="redFontBox">总手续费：<span class="redFont">{{ exhibition(countData.totalRptFee) || 0 }}</span> 元</div>
          <!-- <div class="redFontBox">总收入：<span class="redFont">{{ exhibition(countData.totalIncome) || 0 }}</span> 元</div> -->
          <div class="redFontBox">垫资手续费：<span class="redFont">{{ exhibition(countData.totalRptFeeD0) || 0 }}</span> 元</div>
          <div class="redFontBox">商户结算金额：<span class="redFont">{{ exhibition(countData.totalIncome) || 0 }}</span> 元</div>
          <!-- <div class="redFontBox">总Do分润金额：<span class="redFont">{{countData.totalProfitAmountD0 || 0}}</span> 元</div> -->
        </div>
      </template>
      <template slot="menuRight">
        <el-button type="primary" size="small" @click="setTime('今天')"
          >今天
        </el-button>
        <el-button type="primary" size="small" @click="setTime('昨天')"
          >昨天
        </el-button>
        <el-button type="primary" size="small" @click="setTime('本月')"
          >本月
        </el-button>
        <!-- <el-button
          type="warning"
          size="small"
          plain
          icon="el-icon-download"
          :show-close="false"
          :close-on-click-modal="false"
          @click="excelBox=true"
          >导出
        </el-button> -->
      </template>
      <template slot-scope="scope" slot="menu">
        <el-button
          v-if="permissionList.viewBtn"
          icon="el-icon-view"
          size="small"
          type="text"
          @click.stop="handleDetail(scope.row)"
          >详 情</el-button
        >
      </template>
      <template slot-scope="{}" slot="serviceNoSearch">
        <select-page ref="searchSerSelect" label="serviceName" value="serviceNo" :select.sync="search.serviceNo" :url="website.searchLink.serviceUrl" placeholder-text="服务商" filter-key="searchParam"></select-page>
      </template>
      <template slot-scope="{}" slot="orgNoSearch">
        <select-page ref="searchOrgSelect" label="serviceName" value="serviceNo" :select.sync="search.orgNo" :url="website.searchLink.orgUrl" placeholder-text="机构" filter-key="searchParam"></select-page>
      </template>
      <template slot-scope="{}" slot="rpiNoSearch">
        <select-page ref="searchRpiSelect" label="rpiName" value="rpiNo" :select.sync="search.rpiNo" :url="website.searchLink.merchantUrl" placeholder-text="商户" filter-key="searchParam"></select-page>
      </template>
      <template slot-scope="{}" slot="rpsNoSearch">
        <select-page ref="searchRpsSelect" label="rpsName" value="rpsNo" :select.sync="search.rpsNo" :url="website.searchLink.rpsUrl" placeholder-text="门店" filter-key="searchParam"></select-page>
      </template>
      <template slot-scope="{}" slot="groupRpiSearchKeySearch">
        <select-page ref="searchGroupSelect" label="rpiName" value="rpiNo" :select.sync="search.groupRpiSearchKey" :url="website.searchLink.groupUrl" placeholder-text="集团商户" filter-key="searchParam"></select-page>
      </template>
      <template slot-scope="{}" slot="accountManagerSearch">
        <select-page
          ref="accountManagerSelect"
          label="accountManagerName"
          value="accountManager"
          :select.sync="search.accountManager"
          :url="website.searchLink.accountManager"
          placeholder-text="客户经理"
          filter-key="searchParam"
          :params="accountManagerParams" 
        ></select-page>
      </template>

      <template slot-scope="{disabled,size}" slot="beginTimeSearch">
        <el-date-picker v-model="search.beginTime" type="datetime" :editable="false" :clearable="false" value-format='yyyy-MM-dd HH:mm:ss' @change="beginTimeChange" placeholder="请输入 交易开始日期"></el-date-picker>
      </template>
      <template slot-scope="{disabled,size}" slot="endTimeSearch">
        <el-date-picker v-model="search.endTime" type="datetime" :editable="false" :clearable="false" default-time="23:59:59" value-format='yyyy-MM-dd HH:mm:ss' @change="endTimeChange" placeholder="请输入 交易结束日期"></el-date-picker>
      </template>
    </avue-crud>
   
  </basic-container>
</template>

<script>
import { getList, getListCount,serviceInfoSimpleList,getAccountManager } from "@/api/rb-service/dealManagement/dealManagement";
import { mapGetters } from "vuex";
import { getToken } from "@/util/auth";
import { dateFormat } from "@/util/date";
import selectPage from "@/components/select-page/select-page";

export default {
  components: {
    selectPage
  },
  data() {
    return {
      form: {},
      query: {
        beginTime: dateFormat(new Date(), "yyyy-MM") + "-01 00:00:00",
        endTime: dateFormat(new Date(), "yyyy-MM-dd") + " 23:59:59"
      },
      search: {
        beginTime: dateFormat(new Date(), "yyyy-MM") + "-01 00:00:00",
        endTime: dateFormat(new Date(), "yyyy-MM-dd") + " 23:59:59"
      },
      loading: false,
      page: {
        pageSize: 10,
        currentPage: 1,
        total: 0
      },
      selectionList: [],
      option: {
        height: "calc(50vh - 50px)",
        calcHeight: 30,
        tip: false,
        border: true,
        index: true,
        viewBtn: false,
        editBtn: false,
        addBtn: false,
        delBtn: false,
        selection: true,
        searchMenuSpan: 24,
        columnBtn: false,
        labelWidth: 120, //弹出表单的标题的统一宽度
        searchLabelWidth: 100, //搜索框标题宽度
        menuWidth: 100, //操作栏宽度
        emptyBtnText:'重置',
        // searchIcon:true,
        // searchIndex:3,
        column: [
           {
            label: "订单号",
            prop: "rptOrderCode",
            type: "input",
            search: true,
            overHidden:true,
            minWidth: 220,
            searchOrder: 14
          },
          
          {
            label: "商户编号",
            searchLabel: "商户",
            prop: "rpiNo",
            type: 'select',
            search: true,
            overHidden:true,
            width: 140,
            searchOrder: 0
          },
          {
            label: "门头名称",
            prop: "rpiName",
            type: "input",
            width: 200,
            searchOrder: 1,
            search: true
          },
          {
            label: "集团商户",
            prop: "groupRpiSearchKey",
            type: "select",
            search: true,
            overHidden:true,
            minWidth: 130,
            searchOrder: 7,
            display:false,
            hide:true
            // remote: true,
            // dicUrl: `${baseUrl}/getProvince?id={{key}}`,
          },
          {
            label: "商户简称",
            prop: "userShortName",
            type: "input",
            width: 200,
            hide:true,
            display:false,
            search: true,
            searchOrder: 2
          },
          {
            label: "门店名称",
            prop: "rpsName",
            type: "input",
            search: true,
            searchOrder: 3,
            overHidden:true,
            minWidth: 170
          },
          {
            label: "所属机构",
            prop: "orgNo",
            type: "select",
            dataType: "string",
            searchOrder: 4,
            showColumn: false,
            search: true,
            filterable: true,
            hide: true,
            rules: [
              {
                required: true,
                message: "请选择所属机构",
                trigger: "blur",
              }
            ]
          },
          {
            label: "服务商编号",
            searchLabel: "服务商",
            prop: "serviceNo",
            type: 'select',
            searchOrder: 5,
            search: true,
            span: 24,
            overHidden: true,
            width: 110,
            hide: true,
            display:false
          },
          {
            label: '',
            prop: 'isSelectChild',
            type: 'select',
            multiple: false,
            dataType: "string",
            showColumn: false,
            hide: true,
            search: true,
            searchType:"checkbox",
            searchSpan: 0,
            searchLabelWidth: '0',
            searchOrder: 5,
            dicData: [{
              label:'包含下级',
              value: 1
            }]
          },
          {
            label: "客户经理",
            prop: "accountManager",
            search: true,
            overHidden: true,
            minWidth:200,
            hide: true,
            display:false,
            searchOrder: 6,
            type: "select",
            filterable:true,
            props: {
              label: 'accountManagerName',
              value: 'accountManager',
              desc:'accountManager'
            },
            dicData: [],
          },
          // {
          //   label: "客户经理名称",
          //   prop: "accountManagerName",
          //   type: "input",
          //   search: true,
          //   overHidden: true,
          //   minWidth:200,
          //   hide: true,
          //   display:false,
          //   searchOrder: 6
          // },
          // {
          //   label: "服务商名称",
          //   prop: "serviceName",
          //   type: "input",
          //   overHidden: true,
          //   minWidth:200,
          //   hide: true,
          //   display:false
          // },
          {
            label: "订单金额",//交易金额
            prop: "rptAmount",
            type: "input",
            overHidden:true,
            minWidth: 80,
            search:true,
            searchOrder: 18
          },
          {
            label: "交易手续费",
            prop: "rptFee",
            type: "input",
            minWidth: 92,
            overHidden:true,
          },
          {
            label: "垫资手续费",
            prop: "rptFeeD0",
            type: "input",
            minWidth: 92,
            overHidden:true,
          },
          {
            label: "结算金额",
            prop: "incomeAmount",
            type: "input",
            minWidth: 92,
            overHidden:true,
          },
          {
            label: "交易时间",
            prop: "rptPayTime",
            type: "select",
            // sortable: true,
            overHidden:true,
            minWidth: 140
          },
          {
            label: "交易状态",
            prop: "rptPayState",
            type: "select",
            dataType: "number",
            props: {
              label: "dictValue",
              value: "dictKey"
            },
            search: true,
            dicUrl: "/api/blade-system/dict/dictionary?code=rpt_pay_state",
            formslot:true,
            overHidden:true,
            minWidth: 92,
            searchOrder: 11
          },
          {
            label: "结算方式",
            prop: "settlementMethod",
            type: "select",
            // dataType: "number",
            props: {
              label: "dictValue",
              value: "dictKey"
            },
            dicUrl: "/api/blade-system/dict/dictionary?code=settlement_method",
            formslot:true,
            overHidden:true,
            minWidth: 92
            // search: true,
            // searchOrder: 1
          },
          // {
          //   label: "结算状态",
          //   prop: "settlementState",
          //   type: "select",
          //   dataType: "number",
          //   props: {
          //     label: "dictValue",
          //     value: "dictKey"
          //   },
          //   search: true,
          //   dicUrl: "/api/blade-system/dict/dictionary?code=settlement_state",
          //   formslot:true,
          //   overHidden:true,
          //   minWidth: 92,
          //   searchOrder: 1
          // },
          {
            label: "商户分类",
            prop: "merchantTypeName",
            overHidden:true,
            width: 80
          },
          {
            label: "商户分类",
            prop: "merchantType",
            type: "select",
            props: {
              label: "dictValue",
              value: "dictKey",
            },
            dataType: "number",
            dicUrl: "/api/blade-system/dict/dictionary?code=merchant_type",
            search: true,
            overHidden: true,
            minWidth:80,
            searchOrder: 13,
            display:false,
            hide:true
          },
          {
            label: "订单类型",
            prop: "rptTradeTypeName",
            overHidden:true,
            width: 80
          },
          {
            label: "订单类型",
            prop: "rptTradeType",
            type: "select",
            search: true,
            props: {
              label: "dictValue",
              value: "dictKey",
            },
            dataType: "number",
            dicUrl: "/api/blade-system/dict/dictionary?code=rpt_trade_type",
            overHidden: true,
            minWidth:70,
            searchOrder: 8,
            hide:true
          },
          {
            label: "交易类型",
            prop: "isPosName",
            overHidden:true,
            minWidth: 70
          },
          {
            label: "交易类型",
            prop: "isPos",
            type: "select",
            search: true,
            props: {
              label: "dictValue",
              value: "dictKey",
            },
            dataType: "number",
            dicUrl: "/api/blade-system/dict/dictionary?code=is_pos",
            overHidden: true,
            minWidth:70,
            searchOrder: 9,
            hide:true
          },
          {
            label: "交易方式",
            prop: "rptPayTypeName",
            overHidden:true,
            minWidth: 70
          },
          {
            label: "交易方式",
            prop: "rptPayType",
            type: "select",
            search: true,
            props: {
              label: "dictValue",
              value: "dictKey",
            },
            dataType: "number",
            dicUrl: "/api/blade-system/dict/dictionary?code=rpt_pay_type",
            overHidden:true,
            minWidth: 70,
            searchOrder: 9,
            hide:true
          },
          {
            label: "卡类型",
            prop: "cardTypeName",
            overHidden:true,
            minWidth: 70
          },
          {
            label: "卡类型",
            prop: "cardType",
            type: "select",
            display:false,
            overHidden:true,
            minWidth: 70,
            hide:true,
            props: {
              label: "dictValue",
              value: "dictKey",
            },
            // dataType: "number",
            dicUrl: "/api/blade-system/dict/dictionary?code=card_type",
            search: true,
            searchOrder: 10
          },
          {
            label: "终端编号",
            prop: "rtNo",
            type: "input",
            search: true,
            display:false,
            minWidth: 80,
            overHidden:true,
            searchOrder:12
          },
          {
            label: "官方订单号",
            prop: "rptOtherPayCode",
            type: "input",
            search: true,
            display:false,
            overHidden:true,
            minWidth: 230,
            searchOrder: 15,
          },
          {
            label: "通道订单号",
            prop: "rptAisleOrderCode",
            type: "input",
            search: true,
            display:false,
            overHidden:true,
            minWidth: 180,
            searchOrder: 16
          },
          {
            label: "交易SN号",
            prop: "rsSn",
            type: "input",
            search: true,
            overHidden: true,
            minWidth:200,
            display:false,
            searchOrder: 17
          },
          {
            label: "通道名称",
            prop: "aisleKind",
            type: "select",
            props: {
              label: "dictValue",
              value: "dictKey",
            },
            dataType: "number",
            dicUrl: "/api/blade-system/dict/dictionary?code=aisle_kind",            
            search: true,
            overHidden: true,
            minWidth:80,
            searchOrder: 19,
            display:false,
            hide:true
          },
          {
            label: "交易开始日期",
            prop: "beginTime",
            // type: "datetime",
            // format:'yyyy-MM-dd HH:mm:ss',
            // valueFormat:'yyyy-MM-dd HH:mm:ss',
            // defaultTime:"00:00:00",
            search: true,
            hide: true,
            display: false
          },
          {
            label: "交易结束日期",
            prop: "endTime",
            // type: "datetime",
            // format:'yyyy-MM-dd HH:mm:ss',
            // valueFormat:'yyyy-MM-dd HH:mm:ss',
            // defaultTime:"23:59:59",
            search: true,
            hide: true,
            display: false
          }
        ]
      },
      data: [],
      countData: {},
      accountManagerParams:{}
    };
  },
  computed: {
    ...mapGetters(["permission"]),
    permissionList() {
      return {
        addBtn: this.vaildData(this.permission.trade_add, false),
        viewBtn: this.vaildData(this.permission.trade_view, false),
        delBtn: this.vaildData(this.permission.trade_delete, false),
        editBtn: this.vaildData(this.permission.trade_edit, false),
      };
    },
    ids() {
      let ids = [];
      this.selectionList.forEach((ele) => {
        ids.push(ele.id);
      });
      return ids.join(",");
    },
    // 交易状态
    rptPayStateType() {
      return (row) => {
        if(row.rptPayState==0){
          return '#E6A23C' //未支付
        }else if(row.rptPayState==1&&row.rptIsRefund!==0){
          return '#6463bf' //支付成功（已退款）
        }else if(row.rptPayState==1){
          return '#67C23A' //支付成功
        }else if(row.rptPayState==2){
          return '#909399'    //支付失败
        }else if(row.rptPayState==3){
          return '#909399' //取消支付
        }else if(row.rptPayState==4){
          return '#909399' //退款中
        }else if(row.rptPayState==5){
          return '#2fdeebf2' //已退款
        }else if(row.rptPayState==6){
          return '#909399' //退款失败
        }else{
          return '#909399' 
        }
      };
    },
    exhibition() {
      return (val) => {
        if (val == "" || val == "-1") {
          return (val = 0);
        } else {
          return val;
        }
      };
    },
  },
  watch: {
    "search.serviceNo"(val){
      if(val){
        this.accountManagerParams={serviceNo:val}
        this.$refs.accountManagerSelect.getOptionList(this.accountManagerParams);
      }else{
        this.accountManagerParams={};
        this.search.accountManager="";
        this.$refs.accountManagerSelect.getOptionList({});
      }
    }
  },
  created(){
    // this.getServiceInfoSimpleList({isSelectChild:0})
  },
  methods: {
    beginTimeChange() {
      if(this.search.endTime){
        if( new Date(this.search.beginTime).getFullYear() === new Date(this.search.endTime).getFullYear()){
          if(Date.parse(this.search.beginTime) > Date.parse(this.search.endTime)){
            this.$alert('统计开始日期不能大于结束日期', '提示', {
              confirmButtonText: '确定',
              type: 'warning'
            })
            this.search.beginTime = dateFormat(new Date(this.search.endTime),"yyyy-MM-dd")+' 00:00:00';
          }else if(Date.parse(this.search.beginTime) < Date.parse(this.search.endTime)-3600 * 1000 * 24 * 90){
            this.$alert('日期筛选间隔最大为 3个月', '提示', {
              confirmButtonText: '确定',
              type: 'warning'
            })
            // this.search.beginTime = dateFormat(new Date(this.search.endTime),"yyyy-MM-dd")+' 00:00:00';
            this.search.endTime = dateFormat(new Date(this.search.beginTime),"yyyy-MM-dd")+' 23:59:59';
          }
        }else{
          if(Date.parse(this.search.beginTime) < Date.now() - 3600 * 1000 * 24 * 365 * 2){
            this.$alert('只能查询两年内的数据！', '提示', {
              confirmButtonText: '确定',
              type: 'warning'
            })
            this.search.beginTime = dateFormat(new Date(this.search.endTime),"yyyy-MM-dd")+' 00:00:00';
          }else{
            this.$alert('查询日期不能跨年', '提示', {
              confirmButtonText: '确定',
              type: 'warning'
            })
            // this.search.beginTime = dateFormat(new Date(this.search.endTime),"yyyy-MM-dd")+' 00:00:00';
            this.search.endTime = dateFormat(new Date(this.search.beginTime),"yyyy-MM-dd")+' 23:59:59';
          }
        }
      }
    },
    endTimeChange() {
      if(this.search.beginTime){
        if( new Date(this.search.endTime).getFullYear() === new Date(this.search.beginTime).getFullYear()){
          if(Date.parse(this.search.endTime) < Date.parse(this.search.beginTime)){
            this.$alert('统计结束日期不能小于开始日期', '提示', {
              confirmButtonText: '确定',
              type: 'warning'
            })
            this.search.endTime = dateFormat(new Date(this.search.beginTime),"yyyy-MM-dd")+' 23:59:59';

          }else if(Date.parse(this.search.beginTime)+3600 * 1000 * 24 * 90 < Date.parse(this.search.endTime)){
            this.$alert('日期筛选间隔最大为 3个月', '提示', {
              confirmButtonText: '确定',
              type: 'warning'
            })
            // this.search.endTime = dateFormat(new Date(this.search.beginTime),"yyyy-MM-dd")+' 23:59:59';
            this.search.beginTime = dateFormat(new Date(this.search.endTime),"yyyy-MM-dd")+' 00:00:00';
          }
        }else{
          this.$alert('查询日期不能跨年', '提示', {
              confirmButtonText: '确定',
              type: 'warning'
            })
            // this.search.endTime = dateFormat(new Date(this.search.beginTime),"yyyy-MM-dd")+' 23:59:59';
            this.search.beginTime = dateFormat(new Date(this.search.endTime),"yyyy-MM-dd")+' 00:00:00';
        }
      }
    },
    // 获取 客户经理
    // apiAccountManager(param) {
    //   getAccountManager(param).then((res) => {
    //     const column = this.findObject(this.option.column, "accountManager");
    //     if(res.data.records.length>0){
    //       column.dicData = res.data.records;
    //     }else{
    //       column.dicData = [];
    //     }
    //   })
    // },
     // 获取 代理商
    getServiceInfoSimpleList(param) {
      serviceInfoSimpleList(param).then((res) => {
        // this.rptNoList = res.data.data.records;
        const column = this.findObject(this.option.column, "serviceNo");
        column.dicData = res.data.data;
      })
    },
    /**
     * @func 详情
     * @desc 点击详情进入详情界面
     * @param {Object} row - 商户信息
     * */
    handleDetail(row) {
      this.$router.push({
        name: "交易详情",
        query: {
          rptAisleOrderCode: row.rptAisleOrderCode,
          merchantType:row.merchantType
        },
      });
    },
    /**
     * @func 设置时间
     * @desc 点击获取点击天数时间
     * @param {Object} type - 今天，昨天，近七天
     * */
    setTime(type) {
      let date = new Date();
      this.query = {};
      if (type == "今天") {
        this.search.beginTime = dateFormat(date, "yyyy-MM-dd") +' 00:00:00';
        this.search.endTime = dateFormat(date, "yyyy-MM-dd") +' 23:59:59';
        this.page.currentPage = 1;
        this.forInSearch();
        this.refreshChange();
      } else if (type == "昨天") {
        this.search.beginTime = dateFormat(new Date(date.getTime() - 3600 * 1000 * 24 * 1),"yyyy-MM-dd")+' 00:00:00';
        this.search.endTime = dateFormat(new Date(date.getTime() - 3600 * 1000 * 24 * 1),"yyyy-MM-dd")+' 23:59:59';
        this.page.currentPage = 1;
        this.forInSearch();
        this.refreshChange();
      } else {
        // "本月"
        this.search.beginTime = dateFormat(date,"yyyy-MM")+'-01 00:00:00';
        this.search.endTime = dateFormat(date,"yyyy-MM-dd")+' 23:59:59';
        this.page.currentPage = 1;
        this.forInSearch();
        this.refreshChange();
      }
    },
    forInSearch(){
      for(let key in this.search){
        //console.log(key);
        if(this.search[key]){
          if(key.indexOf("$") == -1 ){
            this.query[key] = this.search[key]
          }
        }
      }
    },
    /**
     * @func edit,view 打开之前回调
     * @desc 点击获取点击天数时间
     * */
    beforeOpen(done, type) {
      if (["edit", "view"].includes(type)) {
        // getDetail(this.form.id).then(res => {
        //   this.form = res.data.data;
        // });
      }
      done();
    },
    /**
     * @func 重置
     * @desc 重置查询条件
     * */
     searchReset() {
      this.query = {
        beginTime: dateFormat(new Date(), "yyyy-MM") + "-01 00:00:00",
        endTime: dateFormat(new Date(), "yyyy-MM-dd") + " 23:59:59"
      },
      this.search = {
        beginTime: dateFormat(new Date(), "yyyy-MM") + "-01 00:00:00",
        endTime: dateFormat(new Date(), "yyyy-MM-dd") + " 23:59:59"
      },

      this.onLoad(this.page);
    },
    /**
     * @func 搜索
     * @desc 根据条件查询
     * @param {params} params --- 条件查询
     * */
    searchChange(params, done) {
      this.query = params;
      this.page.currentPage = 1;
      this.onLoad(this.page, params);
      done();
    },
    /**
     * @func 选中单元格
     * @desc 选中单元格数据
     * @param {list} list --- 选中单元格数据-数组
     * */
    selectionChange(list) {
      this.selectionList = list;
    },
    selectionClear() {
      this.selectionList = [];
      this.$refs.crud.toggleSelection();
    },
    /**
     * @func 分页页码
     * @desc 分页页码改变时会触发
     * */
    currentChange(currentPage) {
      this.page.currentPage = currentPage;
      // this.refreshChange();
      this.onLoad(this.page, this.query);
    },
    /**
     * @func 当前页个数
     * @desc pageSize改变时会触发
     * */
    sizeChange(pageSize) {
      this.page.pageSize = pageSize;
      // this.refreshChange();
      this.onLoad(this.page, this.query);
    },

    /**
     * @func 刷新
     * @desc 点击刷新按钮触发该事件
     * */
    refreshChange() {
      this.onLoad(this.page, this.query);
    },
    /**
     * @func 初始化
     * @desc 表格初始化查询数据
     * */
    onLoad(page, params = {}) {
      this.loading = true;
      // if(this.query.isSelectChildArr){
      //   this.query.isSelectChild = this.query.isSelectChildArr[0];
      // }
      getList(
        page.currentPage,
        page.pageSize,
        Object.assign(params, this.query)
      ).then((res) => {
        const data = res.data.data;
        this.page.total = data.total;
        this.data = data.records;
        this.loading = false;
        this.selectionClear();
      });

      /**
       * @func 统计
       * @desc 根据条件获取统计
       * */
      getListCount(Object.assign(params, this.query)).then((res) => {
        this.countData = res.data.data;
      });
    },
    /**
     * @func 导出
     * @desc 根据条件导出
     * */
    handleExport() {
      let exQuery = ``;
      // exQuery += `&industryCode=${this.search.industryCode}`;//客户经理
      exQuery += `&rptPayType=${this.search.rptPayType}`;
      // exQuery += `&rptPayModel=${this.search.rptPayModel}`;
      exQuery += `&rpiName=${this.search.rpiName}`;
      exQuery += `&rpiNo=${this.search.rpiNo}`;
      exQuery += `&rpsName=${this.search.rpsName}`;
      exQuery += `&rptOrderCode=${this.search.rptOrderCode}`;
      exQuery += `&rptOtherPayCode=${this.search.rptOtherPayCode}`;//官方订单号
      exQuery += `&rtNo=${this.search.rtNo}`;
      exQuery += `&rptRtNo=${this.search.rptRtNo}`;
      exQuery += `&rptAmount=${this.search.rptAmount}`;
      if (this.search.beginTime) {
        exQuery += `&beginTime=${this.search.beginTime}`;
      }
      if (this.search.endTime) {
        exQuery += `&endTime=${this.search.endTime}`;
      }

      this.$confirm("是否导出用户数据?", "提示", {
        confirmButtonText: "确定",
        cancelButtonText: "取消",
        type: "warning",
      }).then(() => {
        window.open(
          `/api/rb-service/service/platformProfit/platform_profit/export?${
            this.website.tokenHeader
          }=${getToken()}` + exQuery
        );
      });
    },
    /**
     * @func 排序
     * @desc 根据表格字段排序
     * */
    sortChange(val) {
      if (val.order == "ascending") {
        //正序
        this.query.ascs = val.prop;
        this.query.descs = "";
      } else {
        //倒序
        this.query.descs = val.prop;
        this.query.ascs = "";
      }
      this.refreshChange();
    },
  },
};
</script>

<style lang="scss" scoped>
.curd-foter {
  // padding-top: 10px;
  display: flex;
  flex-wrap: wrap;
  // margin-bottom: 40px;
}
.el-card__body{
  margin-bottom: 40px;
}
.redFontBox {
  margin-right: 40px;
  .redFont {
    color: red;
  }
}

/deep/ .el-tag--dark.el-tag--success {
  border: none !important;
}
</style>
